﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;

namespace HRWEB.Models
{
    public class UserRolesModel
    {
        public bool IsAdmin { get; set; }
        public bool IsDeptMaster { get; set; }
        public bool IsEduMaster { get; set; }
        public string PublicID { get; set; }
        public string ID { get; set; }
        public UserRolesModel()
        {

        }
        public UserRolesModel(string id)
        {
            using (hrdbEntities ent = new hrdbEntities())
            {
                ID = id;
                PublicID = ent.TEmployees.Where(p => p.FEmployeeID == id).Select(p => p.FPublicID).Single();
                IsAdmin = Roles.IsUserInRole(PublicID, "Admin");
                IsDeptMaster = Roles.IsUserInRole(PublicID, "DeptMaster");
                IsEduMaster = Roles.IsUserInRole(PublicID, "EduMaster");
            }
        }
    }
}